import axios from "axios";
// eslint-disable-next-line
export default {
  // 登录
  login: ({ username, password }) =>
    axios
      .post("/api/admins/login", {
        username,
        password,
      })
      .then(function ({ data }) {
        return data;
      }),
  //注册
  reg: ({ username, password }) =>
    axios
      .post("/api/admins/reg", {
        username,
        password,
      })
      .then(function ({ data }) {
        return data;
      }),
  //保存token与获取token
  setToken: (token) => (localStorage["token"] = token),
  getToken: () => localStorage["token"],
  //获取管理员数据
  getAdmins: ({ curPage, eachPage }) =>
    axios
      .get("/api/admins", {
        params: {
          curPage,
          eachPage,
        },
      })
      .then(({ data }) => data),
};
